home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 January / january_2001.iso / intercd / root / ^4Developers / VB / visbasdb / VBDB / VBDB Code / VB6 Code / Class 6 / Example6-5AD.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-17  |  8.1 KB  |  273 lines

  1. VERSION 5.00
  2. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  3. Begin VB.Form frmAuthors 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Authors"
  6.    ClientHeight    =   2625
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   4680
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   2625
  14.    ScaleWidth      =   4680
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.CommandButton cmdDone 
  17.       Caption         =   "Do&ne"
  18.       Height          =   375
  19.       Left            =   3240
  20.       TabIndex        =   13
  21.       TabStop         =   0   'False
  22.       Top             =   2160
  23.       Width           =   1215
  24.    End
  25.    Begin VB.CommandButton cmdDelete 
  26.       Caption         =   "&Delete"
  27.       Height          =   375
  28.       Left            =   1680
  29.       TabIndex        =   12
  30.       TabStop         =   0   'False
  31.       Top             =   2160
  32.       Width           =   1215
  33.    End
  34.    Begin VB.CommandButton cmdEdit 
  35.       Caption         =   "&Edit"
  36.       Height          =   375
  37.       Left            =   120
  38.       TabIndex        =   11
  39.       TabStop         =   0   'False
  40.       Top             =   2160
  41.       Width           =   1215
  42.    End
  43.    Begin VB.CommandButton cmdCancel 
  44.       Caption         =   "&Cancel"
  45.       Height          =   375
  46.       Left            =   3240
  47.       TabIndex        =   10
  48.       TabStop         =   0   'False
  49.       Top             =   1680
  50.       Width           =   1215
  51.    End
  52.    Begin VB.CommandButton cmdSave 
  53.       Caption         =   "&Save"
  54.       Height          =   375
  55.       Left            =   1680
  56.       TabIndex        =   9
  57.       TabStop         =   0   'False
  58.       Top             =   1680
  59.       Width           =   1215
  60.    End
  61.    Begin VB.CommandButton cmdAddNew 
  62.       Caption         =   "&Add New"
  63.       Height          =   375
  64.       Left            =   120
  65.       TabIndex        =   8
  66.       TabStop         =   0   'False
  67.       Top             =   1680
  68.       Width           =   1215
  69.    End
  70.    Begin VB.CommandButton cmdNext 
  71.       Caption         =   "Next =>"
  72.       Height          =   255
  73.       Left            =   2520
  74.       TabIndex        =   7
  75.       TabStop         =   0   'False
  76.       Top             =   1320
  77.       Width           =   1215
  78.    End
  79.    Begin VB.CommandButton cmdPrevious 
  80.       Caption         =   "<= Previous"
  81.       Height          =   255
  82.       Left            =   1080
  83.       TabIndex        =   6
  84.       TabStop         =   0   'False
  85.       Top             =   1320
  86.       Width           =   1215
  87.    End
  88.    Begin VB.TextBox txtYearBorn 
  89.       DataField       =   "Year Born"
  90.       DataSource      =   "datAuthors"
  91.       Height          =   285
  92.       Left            =   1200
  93.       Locked          =   -1  'True
  94.       TabIndex        =   2
  95.       Text            =   "Text3"
  96.       Top             =   840
  97.       Width           =   1215
  98.    End
  99.    Begin VB.TextBox txtAuthor 
  100.       DataField       =   "Author"
  101.       DataSource      =   "datAuthors"
  102.       Height          =   285
  103.       Left            =   1200
  104.       Locked          =   -1  'True
  105.       TabIndex        =   1
  106.       Text            =   "Text2"
  107.       Top             =   480
  108.       Width           =   3375
  109.    End
  110.    Begin VB.TextBox txtAuthorID 
  111.       DataField       =   "Au_ID"
  112.       DataSource      =   "datAuthors"
  113.       Height          =   285
  114.       Left            =   1200
  115.       Locked          =   -1  'True
  116.       TabIndex        =   3
  117.       TabStop         =   0   'False
  118.       Text            =   "Text1"
  119.       Top             =   120
  120.       Width           =   1215
  121.    End
  122.    Begin MSAdodcLib.Adodc datAuthors 
  123.       Height          =   330
  124.       Left            =   2520
  125.       Top             =   120
  126.       Visible         =   0   'False
  127.       Width           =   2055
  128.       _ExtentX        =   3625
  129.       _ExtentY        =   582
  130.       ConnectMode     =   0
  131.       CursorLocation  =   3
  132.       IsolationLevel  =   -1
  133.       ConnectionTimeout=   15
  134.       CommandTimeout  =   30
  135.       CursorType      =   3
  136.       LockType        =   3
  137.       CommandType     =   1
  138.       CursorOptions   =   0
  139.       CacheSize       =   50
  140.       MaxRecords      =   0
  141.       BOFAction       =   0
  142.       EOFAction       =   0
  143.       ConnectStringType=   1
  144.       Appearance      =   1
  145.       BackColor       =   -2147483643
  146.       ForeColor       =   -2147483640
  147.       Orientation     =   0
  148.       Enabled         =   -1
  149.       Connect         =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Biblio.mdb"
  150.       OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Biblio.mdb"
  151.       OLEDBFile       =   ""
  152.       DataSourceName  =   ""
  153.       OtherAttributes =   ""
  154.       UserName        =   ""
  155.       Password        =   ""
  156.       RecordSource    =   "SELECT * FROM Authors ORDER BY Author"
  157.       Caption         =   "Adodc1"
  158.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  159.          Name            =   "MS Sans Serif"
  160.          Size            =   8.25
  161.          Charset         =   0
  162.          Weight          =   400
  163.          Underline       =   0   'False
  164.          Italic          =   0   'False
  165.          Strikethrough   =   0   'False
  166.       EndProperty
  167.       _Version        =   393216
  168.    End
  169.    Begin VB.Label Label3 
  170.       Caption         =   "Year Born"
  171.       Height          =   255
  172.       Left            =   120
  173.       TabIndex        =   5
  174.       Top             =   840
  175.       Width           =   1215
  176.    End
  177.    Begin VB.Label Label2 
  178.       Caption         =   "Author Name"
  179.       Height          =   255
  180.       Left            =   120
  181.       TabIndex        =   4
  182.       Top             =   480
  183.       Width           =   1215
  184.    End
  185.    Begin VB.Label Label1 
  186.       Caption         =   "Author ID"
  187.       Height          =   255
  188.       Left            =   120
  189.       TabIndex        =   0
  190.       Top             =   120
  191.       Width           =   1215
  192.    End
  193. Attribute VB_Name = "frmAuthors"
  194. Attribute VB_GlobalNameSpace = False
  195. Attribute VB_Creatable = False
  196. Attribute VB_PredeclaredId = True
  197. Attribute VB_Exposed = False
  198. Option Explicit
  199. Private Sub cmdAddNew_Click()
  200. Call SetState("Add")
  201. End Sub
  202. Private Sub cmdCancel_Click()
  203. Call SetState("View")
  204. End Sub
  205. Private Sub cmdDelete_Click()
  206. Dim Response As Integer
  207. Response = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete")
  208. If Response = vbNo Then
  209.   Exit Sub
  210. End If
  211. End Sub
  212. Private Sub cmdEdit_Click()
  213. Call SetState("Edit")
  214. End Sub
  215. Private Sub cmdNext_Click()
  216. datAuthors.Recordset.MoveNext
  217. If datAuthors.Recordset.EOF Then
  218.   Beep
  219.   datAuthors.Recordset.MoveLast
  220. End If
  221. End Sub
  222. Private Sub cmdPrevious_Click()
  223. datAuthors.Recordset.MovePrevious
  224. If datAuthors.Recordset.BOF Then
  225.   Beep
  226.   datAuthors.Recordset.MoveFirst
  227. End If
  228. End Sub
  229. Private Sub cmdSave_Click()
  230. MsgBox "Record saved.", vbOKOnly + vbInformation, "Save"
  231. Call SetState("View")
  232. End Sub
  233. Private Sub SetState(AppState As String)
  234. Select Case AppState
  235. Case "View"
  236.   txtAuthorID.BackColor = vbWhite
  237.   txtAuthor.Locked = True
  238.   txtYearBorn.Locked = True
  239.   cmdPrevious.Enabled = True
  240.   cmdNext.Enabled = True
  241.   cmdAddNew.Enabled = True
  242.   cmdSave.Enabled = False
  243.   cmdCancel.Enabled = False
  244.   cmdEdit.Enabled = True
  245.   cmdDelete.Enabled = True
  246.   cmdDone.Enabled = True
  247.   txtAuthor.SetFocus
  248. Case "Add", "Edit"
  249.   txtAuthorID.BackColor = vbRed
  250.   txtAuthor.Locked = False
  251.   txtYearBorn.Locked = False
  252.   cmdPrevious.Enabled = False
  253.   cmdNext.Enabled = False
  254.   cmdAddNew.Enabled = False
  255.   cmdSave.Enabled = True
  256.   cmdCancel.Enabled = True
  257.   cmdEdit.Enabled = False
  258.   cmdDelete.Enabled = False
  259.   cmdDone.Enabled = False
  260.   txtAuthor.SetFocus
  261. End Select
  262. End Sub
  263. Private Sub Form_Activate()
  264. Call SetState("View")
  265. End Sub
  266. Private Sub txtYearBorn_KeyPress(KeyAscii As Integer)
  267. If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or KeyAscii = vbKeyBack Then
  268.   Exit Sub
  269.   Beep
  270.   KeyAscii = 0
  271. End If
  272. End Sub
  273.